<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>微任务</title>
</head>
<body>
    <script>
        // setTimeout(() => {
        //     console.log(4);
        // });

        // new Promise(resolve => {
        //     resolve();
        //     //在promise里面的也是同步任务
        //     console.log(1);
        // }).then(_=>{
        //     console.log(3);
        // });

        // console.log(2);


        //稍微复杂的任务代码
        setTimeout(() => {
            console.log("定时器");
            setTimeout(() => {
                console.log('timeout timeout');
            },0);

            new Promise(resolve => {
                console.log("timeout Promise");
                resolve();
            }).then(() => {
                console.log("setTimeout then");
            });
        },0);

        new Promise(resolve => {
            console.log("Promise");
            resolve();
        }).then(() => {
            console.log("then");
        });

        console.log("后盾人");

        //promise,后盾人,then,定时器,timeout Promise,setTimeout then,timeout timeout
    </script>
</body>
</html>